package com.wbpay.sdk.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

public class SMSCountDownTimer extends CountDownTimer {

    private TextView mSendButton;
    private Context context;

    public SMSCountDownTimer(long millisInFuture, long countDownInterval,
                             Context context, TextView sendButton) {
        super(millisInFuture, countDownInterval);
        this.mSendButton = sendButton;
        this.context = context;
    }

    @Override
    public void onFinish() {
        mSendButton.setEnabled(true);
        mSendButton.setText(context
                .getString(Utils.getStringId(context, "jy_activity_sms_verify_resend")));
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mSendButton.setEnabled(false);
        mSendButton.setText("(" + millisUntilFinished / 1000 + ")"
                + context.getString(Utils.getStringId(context, "jy_activity_sms_verify_resend")));
    }

}
